package com.zhuidian.mothernote.fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.base.decoration.LinearLayoutDecoration;
import com.base.listener.ItemClickListener;
import com.base.presenter.BasePresenter;
import com.zhuidian.mothernote.R;
import com.zhuidian.mothernote.activity.QuestionCommentActivity;
import com.zhuidian.mothernote.adapter.FollowAdapter;
import com.zhuidian.mothernote.bean.QuestionBean;
import com.zhuidian.mothernote.global.BaseFragment;
import com.zhuidian.mothernote.presenter.FollowPresenter;

import java.util.ArrayList;
import java.util.List;

/*
 * 关注
 * */
public class FollowFragment extends BaseFragment {
    private FollowAdapter adapter;
    private FollowPresenter followPresenter;


    @Override
    protected int inflateMainLayoutId() {
        return R.layout.fragment_follow;
    }

    @SuppressLint("WrongConstant")
    @Override
    protected void initView(View view) {
        RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
        recyclerView.setHasFixedSize(true);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.addItemDecoration(new LinearLayoutDecoration(context, R.drawable.rectangle_solid_c8));
        adapter = new FollowAdapter(context);
        adapter.setOnClickListener(this);
        adapter.setItemClickListener(new ItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                   context.startActivity(new Intent(context, QuestionCommentActivity.class));
            }
        });
        adapter.inflateHeaderView(R.layout.head_line);
        recyclerView.setAdapter(adapter);

    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void initValue() {

    }

    @Override
    protected BasePresenter getPresenter() {
        followPresenter = new FollowPresenter();
        List<QuestionBean> demoList = new ArrayList<QuestionBean>();
        for (int index = 1; index < 20; index++) {
            QuestionBean questionBean = new QuestionBean();
            questionBean.setName("爱回答的小丽妈妈");
            questionBean.setTitle("我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题");
            questionBean.setContent("我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容");
            questionBean.setAgree("200评论");
            questionBean.setLike("100点赞");
            demoList.add(questionBean);

        }
        adapter.setList(demoList);
        return followPresenter;
    }

    @Override
    public void onClick(View view) {

    }


}
